//
//  main.m
//  https
//
//  Created by Mac OS on 16-5-18.
//  Copyright (c) 2016年 lms. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        // insert code here...
       // NSString *For = @"http://www.qq.com";
        NSString *For = @"http://127.0.0.1:3000";
//        NSDictionary *params = @{
//                            @"wd":@"help",
//                            };
//        NSMutableArray *arr = [NSMutableArray new];
//        _Block int i=0;
//        [params enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *obj, BOOL *stop) {
//            
//            NSString *str = [NSString stringWithFormat:@"%@=%@",key,obj];
//            [arr addObject:str];
//           // NSLog(@"%@=%@",key,obj);
//            
//            i += 1;
//        }];
//        
//        NSString *res = [arr componentsJoinedByString:@"&"];
//        res = [res stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
//        res = [NSString stringWithFormat:@"%@?%@",For,res];
//        NSLog(@"%@",res);
        //NSLog(@"%@?%@",For,res);
        
        NSURL *url = [NSURL URLWithString:For];
        NSURLRequest *req = [NSURLRequest requestWithURL:url];
        NSError *err;
        NSHTTPURLResponse *response;
        NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
        if (err) {
            NSLog(@"%@",err);
        }
        
        NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"size:%lu", data.length);
        NSLog(@"%@",str);
            }
    return 0;
}
///参数
//wd   查询的关键词
//pn     显示结果的页数
//cl     搜索类型